package com.junyuan.gsp.util;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: maxwellens
 */
public class StringUtils
{
    public static String concat(List<String> list, String seperator)
    {
        if (list == null || list.size() == 0)
        {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        for (String string : list)
        {
            if (string != null && string.length() > 0)
            {
                sb.append(string).append(seperator);
            }
        }
        if (sb.length() > 0)
        {
            return sb.substring(0, sb.length() - seperator.length());
        } else
        {
            return "";
        }
    }

    public static String concat(List<String> list)
    {
        return concat(list, ",");
    }

    public static String concat(String[] strings, String seperator)
    {
        return concat(Arrays.asList(strings), seperator);
    }

    public static String concat(String... strings)
    {
        return concat(Arrays.asList(strings), ",");
    }

}
